from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import JsonResponse


class LoginRequiredJSONMixin(LoginRequiredMixin):
    """自定义 Mixin 判断用户是否登录"""

    def handle_no_permission(self):
        return JsonResponse({'code': 4101, 'errmsg': '用户未登录'})